import 'package:json_annotation/json_annotation.dart';

part 'chain_lists_model.g.dart';

@JsonSerializable()
class ChainListsModel {
  int total;
  @JsonKey(name: "walletConfig")
  List<ChainConfigObjModel> walletConfig;

  ChainListsModel({required this.total, required this.walletConfig});

  factory ChainListsModel.fromJson(Map<String, dynamic> json) =>
      _$ChainListsModelFromJson(json);

  Map<String, dynamic> toJson() => _$ChainListsModelToJson(this);
}

@JsonSerializable()
class ChainConfigObjModel {
  String chainId;
  String chainName;
  String symbol;
  String icon;
  String browser;
  @JsonKey(name: "chainNodes")
  List<ChainNodesObjModel> chainNodes;
  @JsonKey(name: "tokens")
  List<TokensObjModel>? tokens;
  int sort;

  ChainConfigObjModel({
    required this.sort,
    required this.chainId,
    required this.chainName,
    required this.symbol,
    required this.icon,
    required this.browser,
    required this.chainNodes,
    this.tokens,
  });

  factory ChainConfigObjModel.fromJson(Map<String, dynamic> json) =>
      _$ChainConfigObjModelFromJson(json);

  Map<String, dynamic> toJson() => _$ChainConfigObjModelToJson(this);
}

@JsonSerializable()
class ChainNodesObjModel {
  String rcpUrl;

  ChainNodesObjModel({
    required this.rcpUrl,
  });

  factory ChainNodesObjModel.fromJson(Map<String, dynamic> json) =>
      _$ChainNodesObjModelFromJson(json);

  Map<String, dynamic> toJson() => _$ChainNodesObjModelToJson(this);
}

@JsonSerializable()
class TokensObjModel {
  String symbol;
  String decimal;
  String website;
  String icon;
  String about;
  String name;
  String chain_id;
  String contract_address;
  int display;
  int sort;

  TokensObjModel({
    required this.symbol,
    required this.decimal,
    required this.website,
    required this.icon,
    required this.about,
    required this.name,
    required this.chain_id,
    required this.contract_address,
    required this.display,
    required this.sort,
  });

  factory TokensObjModel.fromJson(Map<String, dynamic> json) =>
      _$TokensObjModelFromJson(json);

  Map<String, dynamic> toJson() => _$TokensObjModelToJson(this);

  @override
  String toString() {
    // TODO: implement toString
    return '{symbol: $symbol,decimal: $decimal,website: $website,icon: $icon,about: $about,name: $name,chain_id: $chain_id,contract_address: $contract_address,display: $display,sort: $sort}';
  }
}
